package com.yun.algorithm.divideandconquer.leetcode;

public class SqrtLeetcode69 {

    static int mySqrt(int x) {
        int left = 1, right = x;
        int r = 0;
        while (left <= right) {
            int m = (left + right) >>> 1;
            if (m <= x / m) {
                left = m + 1;
                r = m;
            } else {
                right = m - 1;
            }
        }
        return r;
    }

    public static void main(String[] args) {
        System.out.println(mySqrt(99));
    }
}
